home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 4 / BBS in a Box - Macintosh - Volume IV (January 1992) (BBS in a Box).iso / Files / Prog / U-Z / WDEF0.TXT < prev    next >
Encoding:
Text File  |  1987-04-26  |  22.5 KB  |  743 lines  |  [TEXT/MACA]

  1.     terse
  2. ;*******************************************************
  3. ;    ZoomWindow ( WDEF0 from System 3.2 )
  4. ;    Commented by
  5. ;    Chris Gehlker
  6. ;    Grand Canyon Code Factory
  7. ;    3158 W. Woodridge Dr.
  8. ;    Phoenix, AZ 85023
  9. ;    (602)    688-9024
  10. ;*******************************************************
  11. ;    This code is no doubt © by Apple Computer
  12. ;    I jobbed comments from Andy Hertzfeld's 1982
  13. ;    version whenever they were appropriate.
  14. ;    WDEF0 was disassembled with TMON
  15. ;*******************************************************
  16. ;    McAssembly V6.2
  17. ;*******************************************************
  18.     ftype    '????'
  19.     if1
  20.     ipath    "Assembler:.PSM files:"
  21.     Incl    "SysEqu.psm"        system equates
  22.     incl    "QuickEqu.PSM"        quick draw equates
  23.     incl    "ToolEqu.PSM"        toolbox equates
  24.     incl    "All Traps.PSM"        register-based trap words
  25.     endi
  26. ;-------------------------------------------------------
  27.     tcomp
  28. ;-------------------------------------------------------
  29. True        equ    $FFFF
  30. False        equ    0
  31. FontInfo    equ    -8
  32. RgnHandle    equ    -12
  33. TextHeight    requ    D7
  34. BoxOffSet    equ    -2
  35.     base    A6,FontInfo,RgnHandle,BoxOffSet
  36.     base    A3,wZoom,wdataHandle,portRect,wVisible,wHilited,StructRgn
  37.     base    A3,wGoAway,portBounds,ContRgn,wTitleWidth
  38. _Debugger    trapw    $A9FF
  39. [[ WDEF,3,$20,TileProc
  40. start    LINK    A6,#-12            set up stack frame
  41.     MOVEM.L    D3-D7/A1-A4,-(SP)    save registers
  42.     MOVE.L    (A5),A0            pointer to current port
  43.     MOVE.L    (A0),-(SP)        save it on the sack
  44.     MOVE.L    WMgrPort,(A0)        set current port to whole screen
  45.     LEA    FontInfo,A3
  46.     GetFontInfo    A3
  47.     MOVE    (A3)+,TextHeight    ascent
  48.     ADD    (A3)+,TextHeight    descent
  49.     ADDQ    #4,TextHeight        D7 is ascent+descent+4
  50.     BSET    #0,TextHeight        round up to odd
  51.     MOVE.L    #19,D1
  52.     CMP    D1,TextHeight        D7 >= 19?
  53.     BGE.S    BigType
  54.     SUB    TextHeight,D1
  55.     LSR    #1,D1            halve D1
  56.     ADD    D1,FontInfo        add D1 to ascent
  57.     MOVE.L    #19,TextHeight        D7 = 19 again
  58. BigType
  59. ; here D7 = Max( ascent+descent+4 rounded, 19)
  60.     MOVE    TextHeight,(A3)+    put D7 in -4(A6)
  61.     MOVE    TextHeight,D0
  62.     SUBI    #13,D0            adjust size
  63.     LSR    #1,D0            halve D0
  64.     MOVE    D0,(A3)            put D0 in BoxOffSet
  65.     NewRgn    =RgnHandle
  66.     LEA    8(A6),A0        get pointer to 1st parameter
  67.     MOVE.L    (A0)+,D3        parameter in D3
  68.     MOVE    (A0)+,D0        message in D0
  69.     MOVE.L    (A0)+,A3        get window pointer
  70.     MOVE    (A0)+,D5        variation code
  71.     MOVE    D5,D6            keep a copy
  72.     ANDI    #3,D5            just DocProc - AltDProc
  73.     CLR.L    (A0)            clear function result
  74. ;-------------------------------------------------------
  75. ; case out on message
  76. ;-------------------------------------------------------
  77.     ADD    D0,D0            double D0
  78.     LEA    MessageJmp,A0        get jump address
  79.     ADD    MessageJmp(D0),A0    compute dispatch
  80.     JSR    (A0)            go for it
  81. ;-------------------------------------------------------
  82. ; standard code for returning to caller
  83. ;-------------------------------------------------------
  84.     DisposRgn    RgnHandle    clean up
  85.     _SetPort            it was saved on the stack
  86.     MOVEM.L    (SP)+,D3-D7/A1-A4    restore registers
  87.     UNLK    A6
  88.     MOVE.L    (SP)+,A0        get return address
  89.     ADD    #12,SP            clear parameters
  90.     JMP    (A0)
  91. ;-------------------------------------------------------
  92. MessageJmp                ; the message jump table
  93.     dw    Draw-MessageJmp
  94.     dw    Hit-MessageJmp
  95.     dw    Calc-MessageJmp
  96.     dw    Init-MessageJmp
  97.     dw    Dispose-MessageJmp
  98.     dw    Grow-MessageJmp
  99.     dw    GrowIcon-MessageJmp
  100. ;-------------------------------------------------------
  101. Init    LOC
  102.     BTST    #3,D6            zoomwindow?
  103.     BEQ.S    .1        nope
  104.     CLR.B    wZoom        clear spareflag
  105.     TST    ROM85        Hey Mac, how old are you?
  106.     BMI.S    .1        can't teach an old dog new tricks
  107.     MOVE.L    #16,D0        size of space
  108.     _NewHandle,CLEAR    16 byte scratch area
  109.     BNE.S    .1        bail out on error
  110.     ADD.B    #1,wZoom    it's done
  111.     MOVE.L    A0,wdataHandle    set handle to scratch record
  112.     MOVE.L    (A0),A4        pointer in A4
  113.  
  114. ; first do the standard state
  115.  
  116.     ADD    #8,A4        point to standard state
  117.     MOVE.L    GrafGlobals(A5),A1        pointer to port
  118.     MOVE.L    screenBits+bounds(A1),(A4)+    load Screenbits.Bounds.topLeft
  119.     MOVE.L    screenBits+bounds+botRight(A1),(A4)+    and botRight
  120.     MOVEQ    #3,D0        set up for inset
  121.     SUB    D0,-(A4)    inset all around
  122.     SUB    D0,-(A4)
  123.     ADD    D0,-(A4)
  124.     ADD    D0,-(A4)
  125.     ADD    TextHeight,(A4)    adjust for title
  126.     ADD    TextHeight,(A4)    twice the font height
  127. ;
  128. ; now do user state
  129. ;
  130.     MOVE.L    (A0),A4        point to user state
  131. ;-------------------------------------------------------
  132. ; On return A4 points to the portRect of the current state
  133. ; in global coordinates.
  134. ;-------------------------------------------------------
  135. GlobalPortRect
  136.     MOVE.L    A4,-(SP)    push scratch area
  137.     MOVE.L    portRect+topLeft(A3),(A4)    put top left of the portRect in scratch area
  138.     MOVE.L    portRect+botRight(A3),4(A4)    now bottom right
  139.     MOVE.L    portBounds(A3),-(SP)    push screen coordinates
  140.     NEG    (SP)
  141.     NEG    2(SP)
  142.     _OffsetRect        convert to global coordinates
  143. .1    RTS
  144. GetState
  145.     LOC
  146.     SUB    #8,SP        put space on stack
  147.     MOVE.L    SP,A4        get a pointer to it
  148.     BSR.S    GlobalPortRect    get the portRect in global coordinates
  149.     MOVE.L    wDataHandle,A0    get handle to the zoom record
  150.     MOVE.L    (A0),A2        pointer to the zoom record
  151.     ADD    #8,A2        point to standard state
  152.     BSR.S    .3        test the topleft corner
  153.     BNE.S    .2        must be user state
  154.     BSR.S    .3        test bottom right corner
  155.     BEQ.S    .1        it was standard state
  156. .2    MOVE.L    wDataHandle,A0    get handle to zoom record
  157.     MOVE.L    (A0),A4        dereference it into A4
  158.     BSR.S    GlobalPortRect    get the portRect in global coordinates
  159.     MOVEQ    #1,D0        signal user state
  160. .1    ADD    #8,SP        remove structure from stack
  161.     RTS
  162. .3    ; test if a point is within 7 pixels of another in each direction
  163.     MOVE.L    (A2),-(SP)    push the point
  164.     MOVE.L    (A2)+,-(SP)    make another copy
  165.     MOVE.L    SP,-(SP)    point at the one point rectangle
  166.     MOVE.L    #$FFF9FFF9,-(SP)    push (-7,-7)
  167.     _InsetRect    a trick to make a 14 X 14 rect centered on the point
  168.     CLR    -(SP)    for result
  169.     MOVE.L    (A4)+,-(SP)    push the point
  170.     PEA    6(SP)        point to the 14 X 14 rect
  171.     _PtInRect
  172.     SUB.B    #1,(SP)
  173.     MOVE.B    (SP)+,D0
  174.     ADD    #8,SP        throw away the stack rect
  175.     RTS
  176.     line
  177. ZoomTest
  178.     LOC
  179.     BTST    #3,D6        is it Zoom?
  180.     BEQ    .1        if not just return
  181.     TST.B    wZoom        test for zoom
  182. .1    RTS
  183. Dispose    BSR.S    ZoomTest
  184.     BEQ.S    .2
  185.     MOVE.L    wDataHandle,A0
  186.     _DisposHandle        if we used a zoom structure, clean it up.
  187. .2    RTS
  188.     line
  189. Draw    LOC
  190.     TST.B    wVisible    is it visible?
  191.     BEQ    DrawDone    if not, do nothing
  192.     CMPI    #wInGoAway,D3    is it a GoAway or zoom click?
  193.     BGE    ZoomOrGoAway    if so, handle it
  194. ;
  195. ; draw the window frame with title bar if appropriate
  196. ;
  197.     PenNormal        use standard pen
  198.     TST    D5        test dialog box flag
  199.     BNE    DrawDBox    dialog box has no title
  200.     BSR    BuildTBarRect    go build the title bar
  201.     PEA    TempRect    TempRect bounds the title bar
  202.     MOVE.L    (SP),-(SP)    push another copy
  203.     MOVE.L    (SP),-(SP)    and yet another
  204.     _FrameRect        frame the title bar
  205.     MOVE.L    OneOne,-(SP)    push inset factor
  206.     _InsetRect        inset it
  207.     _EraseRect        clear inside
  208.     BSR    DoTitleString
  209.     TST.B    wHilited    is it hilited
  210.     BEQ    DrawWindow    if not, then just draw it
  211.     InsetRect    !TempRect,#1,BoxOffSet    inset the title box
  212.     MOVE    TempRect+right,-(SP)    push right
  213.     MOVE    D3,TempRect+right    put title right in TempRect
  214.     MOVE.L    TempRect,D0    get topleft
  215.     ANDI.L    #$00070007,D0    only use mod 8
  216.     MOVE.L    GrafGlobals(A5),A4    get graf globals
  217.     MOVE.L    D0,-168(A4)    nasty nasty messing with QD's privates!
  218.     FillRect    !TempRect,!HilitePattern
  219.     BSR.S    ZoomTest    is it a zoom window?
  220.     BEQ.S    .1        skip if not
  221.     MOVE    (SP),D0        D0 = TempRect right
  222.     SUBI    #26,D0        move left 26 pixels
  223.     CMP    D4,D0        compare to text right
  224.     BGE.S    .1        skip if text fits
  225.     MOVE    D0,D4        clip if it doesn't
  226. .1    MOVE    (SP)+,TempRect+right    restore right edge from stack
  227.     MOVE    D4,TempRect+left    set left edge 26 pixels from right
  228.     FillRect    !TempRect,!HilitePattern
  229.     CLR.L    -168(A4)    Do it again
  230.     TST.B    wGoAway
  231.     BEQ.S    .2        skip if not GoAway
  232.     BSR    BuildTBarRect    build it again based on new TempRect
  233.     LEA    GoAwayData,A1    get pointer to GoAwayData
  234.     MOVE.L    #0,D0        clear out D0
  235.     BSR    LeftBox        draw the box on the left side
  236. .2    BSR.S    ZoomTest    is this a zoom window?
  237.     BEQ.S    DrawWindow    if not, just draw it
  238.     BSR    BuildTBarRect    build the tille bar in TempRect
  239.     LEA    ZoomData,A1    get zoom box data
  240.     MOVEQ    #0,D0
  241.     BSR    RightBox    draw the box on the right side
  242. DrawWindow
  243.     LOC
  244.     MOVE.L    OneOne,D4    load the shadow factor
  245. DrawFrame
  246.     MOVE.L    StructRgn,A0    get handle to StructRgn
  247.     MOVE.L    (A0),A0        dereference it
  248.     LEA    rgnBBox(A0),A4    point A4 at bounding box of StructRgn
  249.     SUB    D4,4(A4)    subtract shadow factor from bottom
  250.     SUB    D4,6(A4)    and from right
  251.     FrameRect    A4
  252.     CMPI    #3,D5        Is it an AltDbox?
  253.     BEQ.S    .3        If so, paint it
  254.     TST    D5        Document Box?
  255.     BNE.S    .1        If not, it has no drop shadow
  256. .3    BSR    PaintDropShadow
  257. ;
  258. ; Draw fancy for dialog box (DBox)
  259. ;
  260. .1    CMP    #1,D5
  261.     BNE.S    .2    If it's a plainDBox, then D0 = 0 and it has no shadow
  262.     MOVE.L    (A4),TempRect        copy bounds into TempRect
  263.     MOVE.L    4(A4),TempRect+4    bottom right too
  264.     PEA    TempRect        push the scratch rectangle
  265.     MOVE.L    (SP),-(SP)    copy it
  266.     MOVE.L    (SP),-(SP)    copy again
  267.     MOVE.L    OneOne,-(SP)    inset 1
  268.     _InsetRect
  269.     MOVE.L    #$00070007,-(SP)
  270.     _PenSize        set pensize
  271.     MOVE.L    GrafGlobals(A5),A0    get pointer to QD globals
  272.     PEA    White(A0)        push white
  273.     _PenPat
  274.     _FrameRect            draw the white stripe
  275.     MOVE.L    GrafGlobals(A5),A0    get pointer to QD globals
  276.     PEA    Black(A0)        push black
  277.     _PenPat
  278.     MOVE.L    #$00020002,-(SP)    push inset factor
  279.     MOVE.L    (SP),-(SP)    push new pen size
  280.     _PenSize
  281.     _InsetRect
  282.     PEA    TempRect    push scratch rectangle again
  283.     _FrameRect        and draw the black penstripe
  284.     _PenNormal
  285. .2    ADD    D4,Bottom(A4)    If we messed with frame for shadowing,
  286.     ADD    D4,Right(A4)    put it back.
  287. DrawDone
  288.     RTS
  289. HilitePattern
  290.     DW    $FF00,$FF00,$FF00,$FF00
  291. ;
  292. ; build a title bar rectangle in the scratch area TempRect.
  293. ; D7 holds height of title bar based on font.
  294. ;
  295. BuildTBarRect
  296.     LEA    TempRect,A0    get pointer to TempRect
  297.     MOVE.L    StructRgn,A1    get StructRgn handle
  298.     MOVE.L    (A1),A1        get StructRgn pointer
  299.     ADD    #RgnBBox,A1    point A1 at bounding box
  300.     MOVE.L    (A1)+,(A0)    copy bounding box into TempRect
  301.     MOVE.L    (A1),4(A0)    both vertices
  302. ;
  303. ; make bottom := top + TextHeight
  304. ;
  305.     MOVE    Top(A0),D0    get top
  306.     ADD    TextHeight,D0    compute top + D7
  307.     MOVE    D0,Bottom(A0)    update bottom
  308.     SUB    #1,Right(A0)    inset right
  309.     RTS            back to caller
  310. ZoomOrGoAway
  311.     LOC
  312.     BEQ.S    .1        it was in the GoAway box
  313.     BSR.S    ZoomTest
  314.     BEQ.S    .2        it wasn't a zoom window
  315.     BSR.S    BuildTBarRect    build the bounding rect
  316.     LEA    ZoomMask,A1    get the bitmap
  317.     MOVEQ    #srcXor,D0    set XOR as plot mode
  318. RightBox
  319.     LEA    TempRect,A0    point A0 at scratch rectangle
  320.     MOVE    Right(A0),Left(A0)    shrink box to a line
  321.     MOVEQ    #-22,D1        set up to inchworm rectangle
  322.     BRA.S    .3
  323. .1    BSR.S    BuildTBarRect    build the title bar
  324.     LEA    GoAwayMask,A1    load the GoAway mask
  325.     MOVEQ    #srcXor,D0    set XOR as plot mode
  326. LeftBox    LEA    TempRect,A0    point A0 at scratch rectangle
  327.     MOVEQ    #7,D1
  328. .3    ADD    D1,Left(A0)    shift left side left by 7 or right by 22
  329.     MOVE    BoxOffSet,D1    load BoxOffSet into D1
  330.     ADD    D1,(A0)        shift bounding rectangle down by adjustment
  331.     SUB    #1,(A0)        and up by one
  332.     MOVE.L    (A0)+,(A0)    copy top left to bottom right
  333.     MOVEQ    #16,D1        set up for shift
  334.     ADD    D1,(A0)+    shift bottom down by 16
  335.     ADD    D1,(A0)        and right over
  336.     MOVE.L    #$00100010,D1    set up boundry rectangle for PlotSymbol
  337.     BSR    PlotSymbol
  338. .2    RTS
  339. ;
  340. ; draw a plain dialog box without title bar
  341. ;
  342. DrawDBox
  343.     MOVE.L    #$00020002,D4    get shadow factor
  344.     CMPI    #3,D5        does it have shadow?
  345.     BEQ.S    DrawFrame    if so, we're cool
  346.     MOVEQ    #0,D4        otherwise no shadow
  347.     BRA.S    DrawFrame    go draw it
  348.  
  349. ; TempRect holds the title bar
  350.  
  351. DoTitleString
  352.     LOC
  353.     MOVE    TempRect+Right,D4    get right
  354.     MOVE    D4,D3            make a copy
  355.     SUB    TempRect+Left,D3    compute width
  356.     SUB    wTitleWidth,D3        compute extra width
  357.     ASR    #1,D3            divide by 2
  358.     MOVEQ    #2,D0
  359.     TST.B    wGoAway        is there a GoAway box
  360.     BEQ.S    .1        skip if not
  361.     MOVEQ    #32,D0        make sure margin is 32 pixels
  362. .1    CMP    D0,D3    Is extra width eneough to show the box?
  363.     BGE.S    .2
  364.     MOVE    D0,D3    If not, make it wider.
  365. .2    ADD    TempRect+Left,D3    compute horizontal start of title
  366.     MOVE    D4,-(SP)    save right coordinate on stack
  367.     BSR.S    ZoomTest    Does this window have a zoom box?
  368.     BEQ.S    .3        skip if not
  369.     SUBI    #32,D4        make space for zoom box
  370. .3    MOVE.L    RgnHandle,-(SP)    push the region handle from frame
  371.     MOVE.L    (SP),-(SP)    make a copy
  372.     _GetClip        save current clipping region
  373.     MOVE    D4,TempRect+Right    put adjusted right coordinate in TempRect
  374.     PEA    TempRect    push TempRect
  375.     _ClipRect        set clipping region to TempRect
  376.     MOVE.L    GrafGlobals(A5),A0    get pointer to QD globals
  377.     MOVE.L    (A0),A0            dereference it
  378.     MOVE.L    ClipRgn(A0),-(SP)    push the clipping region
  379.     MOVE.L    (SP),-(SP)        make a copy
  380. ; Put the intersection of the clipping region and the original clipping
  381. ; region (from the stack frame) into the clipping region.
  382.     _SectRgn
  383.     MOVE    (SP)+,TempRect+Right    restore right coordinate to TempRect
  384.     MOVE    D3,-(SP)    push extra width
  385.     MOVE    TempRect+top,D0    put top corner in TempRect
  386.     ADD    FontInfo,D0    add ascent
  387.     ADDQ    #1,D0        plus one
  388.     MOVE    D0,-(SP)    push the top coordinate
  389.     _MoveTo            move to (top,extra width)
  390.     MOVE.L    wTitleHandle(A3),A0    get title handle
  391.     MOVE.L    (A0),-(SP)        push title pointer
  392.     _DrawString            draw it
  393.     MOVE.L    Rgnhandle,-(SP)    push frame region handle
  394.     _SetClip        restore clipping region
  395.     MOVE    D3,D0        store the left edge of title in D0
  396.     SUBQ    #6,D3        Move it left six pixels
  397.     ADD    wTitleWidth,D0    compute right edge of title
  398.     CMP    D4,D0        does title hang over?
  399.     BGE.S    .4        if not, skip
  400.     MOVE    D0,D4        put right edge in D0
  401. .4    ADDQ    #6,D4        add six
  402.     RTS    ; return with D4 = right edge of title + six D3 = left - six
  403. ZoomData
  404.     DW    $0000,$0000,$BFFB,$2088        data
  405.     DW    $A08B,$2088,$A08B,$2088
  406.     DW    $BF8B,$2008,$A00B,$2008
  407.     DW    $BFFB,$0000,$0000,$0000
  408. ZoomMask
  409.     DW    $0000,$0000,$0000,$0180        mask
  410.     DW    $09A0,$05C0,$0080,$1CF0
  411.     DW    $1F80,$0540,$0920,$0100
  412.     DW    $0000,$0000,$0000,$0000
  413. GoAwayData
  414.     DW    $0000,$0000,$BFFB,$2008        data
  415.     DW    $A00B,$2008,$A00B,$2008
  416.     DW    $A00B,$2008,$A00B,$2008
  417.     DW    $BFFB,$0000,$0000,$0000
  418. GoAwayMask
  419.     DW    $0000,$0000,$0000,$0100        mask
  420.     DW    $0920,$0540,$0000,$1C70
  421.     DW    $0000,$0540,$0920,$0100
  422.     DW    $0000,$0000,$0000,$0000
  423.  
  424. Hit
  425.  
  426. ; On input global mousepoint is in D3 as (v,h)
  427.  
  428.     LOC
  429.     CLR    -(SP)            make room for function result
  430.     MOVE.L    D3,-(SP)        push the mouse point
  431.     MOVE.L    contRgn,-(SP)        push content region handle
  432.     _PtInRgn            is the point in the content region
  433.     TST.B    (SP)+            well, is it?
  434.     BEQ.S    NotInContent        if not, go check out drag region
  435.     TST    D5            is it a dialog box?
  436.     BNE.S    justContent        if so, it's only in the content
  437.     BTST    #2,D6            is it a noGrow window?
  438.     BGT.S    justContent        if so, just do content
  439.     TST.B    wHilited        is it active
  440.     BEQ.S    justContent        if not, it can't be in grow
  441.  
  442. ; test for grow box
  443.  
  444.     MOVE.L    contRgn,A0        get region handle
  445.     MOVE.L    (A0),A0            dereference it
  446.     MOVE.L    RgnBBox+botRight(A0),D0    get bottom right of content
  447.     MOVEQ    #14,D4            keep in register for speed
  448. ;
  449. ; consider horizontal coordinate first
  450. ;
  451.     SUB    D4,D0        offset x by 14 for grow box
  452.     CMP    D0,D3        if <, just in content
  453.     BLT.S    justContent
  454. ;
  455. ; T'aint inside for horizontal so try vertical
  456. ;
  457.     SWAP    D0    put vertical coordinate in low word
  458.     SUB    D4,D0    offset y by 14 for grow box
  459.     SWAP    D3    put y in low word here too
  460.     CMP    D0,D3    is it in the grow box?
  461.     BLT.S    justContent    if not, it must be in content
  462.     MOVEQ    #wInGrow,D0    return InGrow flag
  463.     BRA    HitDone
  464. justContent
  465.     MOVEQ    #wInContent,D0    return InContent flag
  466.     BRA    HitDone
  467. ;
  468. ; It aint in content, see if it's in drag (region)
  469. ;
  470. NotInContent
  471.     TST    D5        is it a dialog box
  472.     BNE    DoneHitComplete    dialog box has no drag region
  473.     BSR.S    BuildTBarRect    build title bar in TempRect and point A0 at it
  474.     CLR    -(SP)        function result space
  475.     MOVE.L    D3,-(SP)    push mouse point
  476.     MOVE.L    A0,-(SP)    push TempRect
  477.     _PtInRect        is the point in the rect
  478.     TST.B    (SP)+        is it?
  479.     BEQ.S    DoneHitComplete    If not, it wasn't in window
  480.  
  481. ; It's somewhere in the title bar. Is it in zoom or goAway box?
  482.  
  483.     TST.B    wHilited    is it hilited
  484.     BEQ.S    ItsInDrag    wears masculine clothes if not hilited
  485.     MOVE.L    D3,D0        put mouse point in D0
  486.     SWAP    D0        move vertical coordinate to low word
  487.     ADD    portBounds,D0    convert to relative to top of content region
  488.     SUB    portRect,D0    in case content origin not (0,0)
  489.     ADD    BoxOffSet,D0    add offset to zoom or goAway box
  490.     BPL.S    ItsInDrag    mouse click was below box
  491.     ADDI    #11,D0        test other side
  492.     BMI.S    ItsInDrag    click was above box
  493.     TST.B    wGoAway        does it have a GoAway box?
  494.     BEQ.S    .1        if not, see about Zoom box
  495.     MOVE.L    D3,D0        put mousepoint back
  496.     ADD    portBounds+left(A3),D0    adjust to left of window
  497.     SUB    portRect+left(A3),D0    in case origin not (0,0)
  498.     CMP    #18,D0        is it too far right?
  499.     BGT.S    .1        go test for zoom window
  500.     SUBQ    #8,D0        test other side
  501.     BMI.S    ItsInDrag    it was too far left
  502.     MOVEQ    #wInGoAway,D0    bingo!, the GoAway box
  503.     BRA.S    HitDone        return with answer
  504. .1    BSR.S    ZoomTest    see if it's a zoom window
  505.     BEQ.S    ItsInDrag    if not, point must be in drag
  506.     MOVE    D3,D0        put x in D0
  507.     ADD    portBounds+left(A3),D0    change left side to global
  508.     SUB    portRect+right(A3),D0    adjust to right side
  509.     CMPI    #-19,D0            compare to left side of box
  510.     BLT.S    ItsInDrag        too far left
  511.     CMPI    #-9,D0            check out right side
  512.     BGT.S    ItsInDrag        too far right
  513.     BSR    GetState        go see if it's zoom in or out
  514.     BEQ.S    .2            it was in standard state
  515.     MOVEQ    #wInZoomOut,D0        it must have been in user state
  516.     BRA.S    HitDone
  517. .2    MOVEQ    #wInZoomIn,D0        it must have been in standard state
  518.     BRA.S    HitDone
  519. ItsInDrag
  520.     MOVEQ    #wInDrag,D0        signal drag region
  521. HitDone    MOVE.L    D0,20(A6)    return result on stack
  522. DoneHitComplete
  523.     RTS
  524. Calc    LOC
  525. ;*******************************************************
  526. ; This code is from the original Apple WDEF0. It is a
  527. ; high level NOOP
  528. ;    BSR    ZoomTest    Is it a zoom window?
  529. ;    BEQ.S    .1        Only zoom windows have states.
  530. ;    BSR    GetState
  531. ;*******************************************************
  532. ;
  533. ;-------------------------------------------------------
  534. ; First calculate content region.
  535. ;-------------------------------------------------------
  536. .1    LEA    TempRect,A0    get pointer to working rectangle
  537.     MOVE.L    A0,-(SP)    push pointer for later offset
  538.     MOVE.L    portRect,(A0)+    copy topLeft of portRect
  539.     MOVE.L    portRect+botRight,(A0)    copy bottom right of portRect
  540. ;
  541. ; offset to global coordinates
  542. ;
  543.     MOVE.L    portbounds,-(SP)
  544.     NEG    0(SP)        negate offset
  545.     NEG    2(SP)        both words
  546.     _OffsetRect        offset TempRect    to global coordinates
  547.     MOVE.L    contRgn,-(SP)    content region gets the result
  548.     PEA    TempRect
  549.     _RectRgn
  550. ;
  551. ; Now do the structure region.  First convert the boundry rectangle
  552. ; (TempRect) to structure isnstead of content.
  553. ;
  554.     MOVE.L    #$00020002,D4    get the shadow factor for DBox
  555.     MOVE.L    structRgn,-(SP)    push the structure region for later
  556.     PEA    TempRect    push a pointer to the rect
  557.     MOVE.L    (SP),-(SP)    make two copies
  558.     MOVE.L    MinusOne,-(SP)    make one pixel bigger, all around
  559.     _InsetRect        make it bigger
  560.     TST    D5        is it a DBox?
  561.     BNE.S    DoDBoxCalc    skip if it is
  562.     MOVE    TextHeight,D0    
  563.     SUBQ    #1,D0
  564.     SUB    D0,TempRect+Top    make it D7 - 1 pixel higher
  565.     LSR.L    #1,D4        adjust shadow factor
  566. CalcCommon
  567.     _RectRgn        RectRgn (structRgn,TempRect)
  568. ;
  569. ; add drop shadow if necessary
  570. ;
  571.     TST    D5        is it a document window?
  572.     BEQ.S    .2        if so, skip
  573.     CMPI    #3,D5        is it an altDBox window?
  574.     BNE.S    NoDropShadow
  575. .2    MOVE.L    RgnHandle,-(SP)    push the region handle
  576.     PEA    TempRect    push TempRect
  577.     MOVE.L    (SP),-(SP)    make another copy
  578.     MOVE.L    D4,-(SP)    push shadow factor
  579.     _OffsetRect        offset it
  580.     _RectRgn
  581.     MOVE.L    structRgn,-(SP)
  582.     MOVE.L    RgnHandle,-(SP)    offset region
  583.     MOVE.L    structRgn,-(SP)    structRgn gets the result
  584.     _UnionRgn        add it in
  585. NoDropShadow
  586.     RTS
  587. DoDBoxCalc
  588.     CMPI    #1,D5        is it a dBox?
  589.     BNE.S    CalcCommon
  590.     PEA    TempRect    push our rectangle
  591.     MOVE.L    #$FFF9FFF9,-(SP)    push (-7,-7)
  592.     _InsetRect
  593.     BRA.S    CalcCommon
  594. ;-------------------------------------------------------
  595. Grow
  596. ;-------------------------------------------------------
  597. ; first make it one pixel bigger
  598.     MOVE.L    D3,-(SP)        push the rect
  599.     MOVE.L    MinusOne,-(SP)        push (-1,-1)
  600.     _InsetRect
  601.     MOVE.L    D3,A3        get rect handle in A3
  602.     MOVE.L    (A3),-(SP)    push rect pointer
  603.     MOVE    TextHeight,D0
  604.     SUBQ    #1,D0
  605.     SUB    D0,(A3)
  606.     MOVE.L    D3,-(SP)    push the rectangle
  607.     _FrameRect        frame it
  608.     MOVE    Left(A3),-(SP)    push left
  609.     MOVE    bottom(A3),-(SP)    push bottom
  610.     SUB    #16,(SP)    really 16 pixels above bottom
  611.     MOVE.L    (SP),-(SP)    make a copy of this point
  612.     _MoveTo            move to it
  613.     MOVE    right(A3),2(SP)    now go to the right edge
  614.     _LineTo            draw the horizontal line
  615. ;
  616. ; draw the upper horizontal line
  617. ;
  618.     MOVE.L    (SP),topLeft(A3)
  619.     MOVE.L    (SP),-(SP)
  620.     _MoveTo
  621.     MOVE    right(A3),2(SP)
  622.     _LineTo
  623. ;
  624. ; draw vertical line
  625. ;
  626.     MOVE    right(A3),-(SP)    push right
  627.     SUB    #16,(SP)    really want  right-16
  628.     MOVE    top(A3),-(SP)
  629.     MOVE.L    (SP),-(SP)
  630.     _MoveTo
  631.     MOVE    bottom(A3),(SP)
  632.     _LineTo
  633. ; return our rect to original
  634.     MOVE.L    D3,-(SP)    push to inset
  635.     MOVE.L    OneOne,-(SP)    push (1,1)
  636.     _InsetRect
  637.     RTS
  638.  
  639. ; Paint a drop shadow around the window.  Shadow factor is in D4:
  640. ; A4 points at bounding box of structure region.
  641.  
  642. PaintDropShadow
  643.     MOVE.L    D4,-(SP)    push shadow factor
  644.     _Pensize        make pensize = shadow factor
  645.     MOVE    right(A4),D0    get right of structure rect
  646.     MOVE    D0,-(SP)    push right
  647.     MOVE    top(A4),-(SP)    push top
  648.     ADD    D4,(SP)        want top + shadow
  649.     MOVE    D0,-(SP)    push right
  650.     MOVE    bottom(A4),D0    get bottom
  651.     MOVE    D0,-(SP)    push bottom
  652.     MOVE    left(A4),-(SP)    push left
  653.     ADD    D4,(SP)        want left + shadow
  654.     MOVE    D0,-(SP)    push bottom
  655.     _MoveTo            MoveTo(left+shadow,bottom)
  656.     _Lineto            LineTo(right,bottom)
  657.     _LineTo            LineTo(right,top+shadow)
  658.     _PenNormal        restore pen
  659.     RTS
  660. ;
  661. ; PlotSymbol - plot the little 16 by 16 symbol bitmap pointed to
  662. ; by A1 into the rectangle held in TempRect. D0 holds mode.
  663. ;
  664. PlotSymbol
  665.     LEA    IconBitMap,A0    get pointer to source bitmap
  666.     MOVE.L    A1,(A0)+    update base address of bitmap
  667.     MOVE    #2,(A0)+    update rowBytes
  668.     CLR.L    (A0)+        topLeft is (0,0)
  669.     MOVE.L    D1,(A0)        adjust boundsRect
  670. ;
  671. ; push parameters for CopyBits call to transfer arrow bitMap
  672. ;
  673.     PEA     IconBitMap    push pointer source bitmap
  674.     MOVE.L  (SP),A0        remember in A0, too
  675.     MOVE.L  GrafGlobals(A5),A1    get GrafGlobals baseaddress
  676.     MOVE.L  thePort(A1),A1        get thePort
  677.     PEA     portBits(A1)        that's the destination bitmap
  678.     PEA     bounds(A0)    boundsRect of bitmap is source
  679.     PEA    TempRect    TempRect is the destination
  680.     MOVE.W    D0,-(SP)    theMode is in D0
  681.     CLR.L   -(SP)        no mask region
  682. ;
  683. ; transfer the bitMap (stretching as necessary...)
  684. ;
  685.     _CopyBits        let Bill stretch those bits
  686.     RTS        bye now
  687. ; Draw the grow icon.  First make this window the current grafPort
  688. GrowIcon
  689.     MOVE.L  A3,-(SP)    push it
  690.     _SetPort        make that the port
  691.  
  692. ;  compute the grow icon rectangle in tempRect
  693.  
  694.     LEA    TempRect,A4    get pointer to tempRect
  695.  
  696. ; copy in botRight of tempRect
  697.  
  698.     MOVE.L    PortRect+botRight(A3),botRight(A4)
  699.     MOVE.L  botRight(A4),topLeft(A4)    into the topLeft, too
  700.     SUB    #15,top(A4)            subtract from Top
  701.     SUB    #15,left(A4)            and left, too
  702. ;
  703. ; plot the grow icon
  704.  
  705.     TST.B   wHilited    is it hilited?
  706.     BEQ.S   ClearGoAway    if not, go clear it
  707.     LEA    GrowBits,A1    get pointer to the bits
  708.     MOVEQ   #0,D0        use srcCopy
  709.     MOVE.L  #$00100010,D1
  710.     BSR.S    PlotSymbol    plot it
  711.  
  712. ; plot the boundry line
  713. PlotBoundary
  714.     MOVE    left(A4),-(SP)    push tempRect.left
  715.     MOVE    (SP),-(SP)    copy it again for later
  716.     MOVE    portRect+top(A3),-(SP)    push portRect.top
  717.     _MoveTo                move to it
  718.     MOVE    portRect+bottom(A3),-(SP)    push portRect.bottom
  719.     _LineTo                draw the vertical line
  720. ;
  721. ; now draw the horizontal line
  722. ;
  723.     MOVE    portRect+left(A3),-(SP)    push portRect.left
  724.     MOVE    top(A4),-(SP)        push tempRect.top
  725.     _MoveTo
  726.     MOVE    portRect+right(A3),-(SP)    push portRect.right
  727.     MOVE    top(A4),-(SP)        push tempRect.top
  728.     _LineTo
  729.     RTS
  730. ClearGoAway
  731.     PEA     TempRect
  732.     _EraseRect
  733.     BRA.S    PlotBoundary
  734. ;
  735. ; BitMap for GrowIcon
  736. ;
  737. GrowBits
  738.     dw    $0000,$0000,$0000,$1FE0
  739.     dw    $1020,$103E,$1022,$1022
  740.     dw    $1022,$1022,$1FE2,$0402
  741.     dw    $0402,$0402,$07FE,$0000
  742. ]]
  743.     END